home *** CD-ROM | disk | FTP | other *** search
/ Megahits 3 / Megahits 3 (1994)(GTI - Rhein-Main-Soft)(DE)[!].iso / module / utilities / archives / k1ed_v5_31.lha / src / multied.c < prev    next >
C/C++ Source or Header  |  1992-10-29  |  26KB  |  1,154 lines

  1. #include "inc.h"
  2. #include "defs.h"
  3. #include "req_manx_5.c"
  4. #include "zz_pointer.h"
  5. #include <exec/memory.h>
  6.  
  7. struct Image Image1 = {
  8.     0,67,
  9.     4,4,
  10.     0,
  11.     NULL,
  12.     0x0000,0x0000,
  13.     NULL
  14. };
  15.  
  16. extern struct Gadget Gadget1; 
  17. extern struct PropInfo Gadget1SInfo; 
  18. extern int initmul[76];
  19. extern struct GetStringStruct strstruct;                
  20.  
  21. char *ToneName[12] =
  22. {    "C ","C#","D ","D#","E ","F ","F#","G ","G#","A ","B ","H "
  23. };
  24.  
  25. int soundnr[8];
  26. int banknr[8];
  27. int zonelow[8];
  28. int zonehigh[8];
  29. int poly[8];
  30. int output[8];
  31. int mode[8];
  32. int rcvch[8];
  33. int velo[8];
  34. int transpose[8];
  35. int tune[8];
  36. int level[8];
  37. int mastervolume;
  38. long oldvol;
  39.  
  40. char name[11];
  41.  
  42. /* multied.c */
  43. void DecodeMulti(const int nr);
  44. void MultiEd(const int nr);
  45. void DisplaySingleEdWindow(void);
  46. void DisplayMultiEdWindow(void);
  47. void EncodeMulti(int nr);
  48. int MultiProp(int current, int max, int flag);
  49. void DisplayLine(const int i);
  50. void DisplayMultiValue(int flag,int val);
  51. void TestMultiPatch(void);
  52.  
  53. unsigned char M[76];
  54.  
  55. /**********************************************************************************/
  56. /***                                                                            ***/
  57. /**********************************************************************************/
  58.  
  59. void DecodeMulti(const int nr)
  60. {
  61.     int i;
  62.  
  63.     mastervolume=m[nr][10];
  64.     for (i=0; i<=7; i++)                        /* Daten dekodieren */
  65.     {
  66.         int modelsb,modemsb;
  67.  
  68.         soundnr[i]    = (m[nr][11+i] & 7);
  69.         banknr[i]   = (m[nr][11+i] & 56) >> 3;
  70.  
  71.         zonelow[i]    = m[nr][19+i];
  72.         zonehigh[i]    = m[nr][27+i];
  73.  
  74.         poly[i]        = m[nr][35+i] & 15;
  75.         output[i]    = (m[nr][35+i] & 48) >> 4;
  76.         modelsb        = (m[nr][35+i] & 64) >> 6;
  77.  
  78.         modemsb        = (m[nr][43+i] & 64) >> 6;
  79.         rcvch[i]    = m[nr][43+i] & 15;
  80.         velo[i]        = (m[nr][43+i] & 48) >> 4;
  81.  
  82.         transpose[i]= m[nr][51+i];
  83.         tune[i]     = m[nr][59+i];
  84.         level[i]    = m[nr][67+i];
  85.         mode[i]     = 2*modemsb+modelsb;
  86.     }
  87. }
  88.  
  89. void MultiEd(const int nr)
  90. {
  91.     int i,j,refresh,startup=0;
  92.     int x,y,mx,my;    
  93.     char string[255],title[255];
  94.  
  95.     oldvol=Gadget1SInfo.VertPot;
  96.  
  97.     for (i=0;i<=75;i++) M[i]=m[nr][i];            /* Daten sichern für Cancel */
  98.  
  99.     DecodeMulti(nr);
  100.     refresh=0;    
  101.  
  102. aufbau: ;
  103.  
  104.     SetAPen(win->RPort,0);
  105.     SetBPen(win->RPort,0);    
  106.     SetOPen(win->RPort,0);
  107.     RectFill(win->RPort,10,11,616,250);
  108.  
  109.     Print(win,571,21," O K ");
  110.     MakeDBox(win,567,13,614,23);
  111.  
  112.     Print(win,562,35,"Undo");
  113.     MakeDBox(win,548,27,606,37);
  114.  
  115.     Print(win,557,50,"Print");
  116.     MakeDBox(win,548,42,606,52);
  117.  
  118.     Print(win,553,65,"Rename");
  119.     MakeDBox(win,548,57,606,67);
  120.  
  121.     Print(win,562,80,"Init");
  122.     MakeDBox(win,548,72,606,82);
  123.  
  124.     Print(win,562,95,"Test");
  125.     MakeDBox(win,548,87,606,97);
  126.  
  127.     Print(win,562,110,"Copy");
  128.     MakeDBox(win,548,102,606,112);
  129.  
  130.     Print(win,562,125,"Swap");
  131.     MakeDBox(win,548,117,606,127);
  132.  
  133.  
  134.     for (j=0;j<=1;j++)
  135.         for(i=0;i<=4;i++)
  136.             MakeDBox(win,20+80*i,160+15*j,90+80*i,170+15*j);
  137.     
  138.     
  139.     Print(win,24+80*0,168,"ZL = C-2");
  140.     Print(win,24+80*1,168,"ZH = G 8");
  141.     Print(win,24+80*2,168,"Ch = 1-8");
  142.     Print(win,24+80*3,168,"Velo=All");
  143.     Print(win,24+80*4,168,"Out =L+R");
  144.  
  145.     Print(win,24+80*0,183,"Poly= VR");
  146.     Print(win,24+80*1,183,"Mode=Mix");
  147.     Print(win,24+80*2,183,"Trans= 0");
  148.     Print(win,24+80*3,183,"Tune = 0");
  149.     Print(win,24+80*4,183,"Lev =100");
  150.  
  151. aufbau1: ;
  152.     for (i=0;i<=9;i++) name[i]=m[nr][i]; name[10]='\0';
  153.     strcpy(title,"KAWAI K1-II Librarian...Multipatch-Editor   Selected: ");
  154.     strcat(title,name);
  155.     SetTitle(title);
  156.  
  157.     Print(win,120,25,"ZoneL");
  158.     Print(win,170,25,"ZoneH");
  159.     Print(win,220,25,"Ch");
  160.     Print(win,254,25,"Velo");
  161.     Print(win,302,25,"Out");
  162.     Print(win,335,25,"Poly");
  163.     Print(win,374,25,"Mode");
  164.     Print(win,414,25,"Trans");
  165.     Print(win,458,25,"Tune");
  166.     Print(win,497,25,"Level");
  167.  
  168.     Gadget1SInfo.VertPot=65535-mastervolume*656;
  169.     RefreshGadgets(&Gadget1,win,NULL); 
  170.     
  171. start: ;
  172.     for (i=0;i<=7;i++)    DisplayLine(i);    
  173.  
  174.     Line(win,15,30+15*i,540,30+15*i);
  175.     Line(win,15,30,15,150);
  176.     Line(win,115,30,115,150);
  177.     Line(win,165,30,165,150);
  178.     Line(win,215,30,215,150);
  179.     Line(win,245,30,245,150);
  180.     Line(win,295,30,295,150);
  181.     Line(win,335,30,335,150);
  182.     Line(win,365,30,365,150);
  183.     Line(win,415,30,415,150);
  184.     Line(win,455,30,455,150);
  185.     Line(win,495,30,495,150);
  186.     Line(win,540,30,540,150);
  187.  
  188.     if (refresh != 0) 
  189.     {
  190.         Forbid();
  191.         BeginRefresh(win);
  192.         RefreshWindowFrame(win);
  193.         EndRefresh(win,i);
  194.         Permit();
  195.         refresh=0;
  196.     }
  197.  
  198.     if (startup==0)
  199.     {
  200.         ProgChange(64+nr);
  201.         startup=1;
  202.     }
  203.     else EncodeMulti(nr);
  204.  
  205. Loop: RefreshGadgets(&Gadget1,win,NULL); 
  206.     MODWIN
  207.     WaitPort(win->UserPort);
  208.  
  209.     while(mesg = (struct IntuiMessage *) GetMsg(win->UserPort))
  210.     {
  211.         class=mesg->Class;
  212.         code=mesg->Code;
  213.         x=mesg->MouseX;
  214.         y=mesg->MouseY;
  215.         ReplyMsg((struct Message *)mesg);
  216.     
  217.         switch(class)
  218.         {
  219.             case ACTIVEWINDOW:
  220.             {
  221.                 if (SCREEN==NULL) SetColours();
  222.                 break;
  223.             }
  224.     
  225.             case INACTIVEWINDOW:
  226.             {
  227.                 if (SCREEN==NULL) SetOldColours();
  228.                 break;
  229.             }
  230.         
  231.             case NEWSIZE:
  232.             {
  233.                 refresh=1;
  234.                 goto aufbau;            
  235.                 break;
  236.             }
  237.     
  238.             case CLOSEWINDOW:
  239.             {   
  240.                 Quit();
  241.                 break;
  242.             }
  243.     
  244.             case GADGETUP:
  245.             {
  246.                 EncodeMulti(nr);
  247.                 break;
  248.             }    
  249.     
  250.             case MOUSEBUTTONS:
  251.             {
  252.                 if (code==MENUDOWN)                                /* OK */
  253.                 {
  254.                 /*    EncodeMulti(nr);
  255.                     SetAPen(win->RPort,0);
  256.                     SetBPen(win->RPort,0);    
  257.                     SetOPen(win->RPort,0);
  258.                     RectFill(win->RPort,10,11,616,250);
  259.                     Gadget1SInfo.VertPot=oldvol;
  260.                     RefreshGadgets(&Gadget1,win,NULL); 
  261.                     multi=1;
  262.                     Display();
  263.                     return();    */
  264.                 }
  265.     
  266.                 if (code==SELECTDOWN)
  267.                 {
  268.                     if (Check(x,y,20,90,160,170))                /* ZoneLow */
  269.                     {
  270.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  271.                         {
  272.                             for (i=0;i<=7;i++)
  273.                             {
  274.                                 zonelow[i]=0;
  275.                                 DisplayLine(i);
  276.                             }    
  277.                             EncodeMulti(nr);
  278.                         }
  279.                     }
  280.     
  281.                     if (Check(x,y,100,170,160,170))                /* ZoneHigh */
  282.                     {
  283.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  284.                         {
  285.                             for (i=0;i<=7;i++)
  286.                             {
  287.                                 zonehigh[i]=127;
  288.                                 DisplayLine(i);
  289.                             }    
  290.                             EncodeMulti(nr);
  291.                         }
  292.                     }
  293.     
  294.                     if (Check(x,y,180,250,160,170))                /* Channel */
  295.                     {
  296.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  297.                         {
  298.                             for (i=0;i<=7;i++)
  299.                             {
  300.                                 rcvch[i]=i;
  301.                                 DisplayLine(i);
  302.                             }    
  303.                             EncodeMulti(nr);
  304.                         }
  305.                     }
  306.     
  307.                     if (Check(x,y,260,330,160,170))                /* Velo */
  308.                     {
  309.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  310.                         {
  311.                             for (i=0;i<=7;i++)
  312.                             {
  313.                                 velo[i]=0;
  314.                                 DisplayLine(i);
  315.                             }    
  316.                             EncodeMulti(nr);
  317.                         }
  318.                     }
  319.     
  320.                     if (Check(x,y,340,410,160,170))             /* Output */
  321.                     {
  322.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  323.                         {
  324.                             for (i=0;i<=7;i++)
  325.                             {
  326.                                 output[i]=1;
  327.                                 DisplayLine(i);
  328.                             }    
  329.                             EncodeMulti(nr);
  330.                         }
  331.                     }
  332.     
  333.                     if (Check(x,y,20,90,175,185))                /* Poly */
  334.                     {
  335.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  336.                         {
  337.                             for (i=0;i<=7;i++)
  338.                             {
  339.                                 poly[i]=0;
  340.                                 DisplayLine(i);
  341.                             }    
  342.                             EncodeMulti(nr);
  343.                         }
  344.                     }
  345.     
  346.                     if (Check(x,y,100,170,175,185))                /* Mode */
  347.                     {
  348.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  349.                         {
  350.                             for (i=0;i<=7;i++)
  351.                             {
  352.                                 mode[i]=2;
  353.                                 DisplayLine(i);
  354.                             }    
  355.                             EncodeMulti(nr);
  356.                         }
  357.                     }
  358.     
  359.                     if (Check(x,y,180,250,175,185))                /* Trans */
  360.                     {
  361.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  362.                         {
  363.                             for (i=0;i<=7;i++)
  364.                             {
  365.                                 transpose[i]=24;
  366.                                 DisplayLine(i);
  367.                             }    
  368.                             EncodeMulti(nr);
  369.                         }
  370.                     }
  371.     
  372.                     if (Check(x,y,260,330,175,185))                    /* Tune */
  373.                     {
  374.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  375.                         {
  376.                             for (i=0;i<=7;i++)
  377.                             {
  378.                                 tune[i]=50;
  379.                                 DisplayLine(i);
  380.                             }    
  381.                             EncodeMulti(nr);
  382.                         }
  383.                     }
  384.     
  385.                     if (Check(x,y,340,410,175,185))                    /* Level */
  386.                     {
  387.                         if (MyReq("Please confirm choice !","Confirm","Cancel"))
  388.                         {
  389.                             for (i=0;i<=7;i++)
  390.                             {
  391.                                 level[i]=100;
  392.                                 DisplayLine(i);
  393.                             }    
  394.                             EncodeMulti(nr);
  395.                         }
  396.                     }
  397.     
  398.                     if (Check(x,y,567,614,13,23))                    /* OK */
  399.                     {
  400.                         EncodeMulti(nr);
  401.                         SetAPen(win->RPort,0);
  402.                         SetBPen(win->RPort,0);    
  403.                         SetOPen(win->RPort,0);
  404.                         RectFill(win->RPort,10,11,616,250);
  405.                         Gadget1SInfo.VertPot=oldvol;
  406.                         RefreshGadgets(&Gadget1,win,NULL); 
  407.                         multi=1;
  408.                         Display();
  409.                         return();
  410.                     }        
  411.     
  412.                     if (Check(x,y,548,606,27,37))                /* Undo */
  413.                     {
  414.                         int j;
  415.                         if (MyReq("Are you shure ?"," Yes ","Oh no"))
  416.                         {
  417.                             for (j=0;j<=75;j++) m[nr][j]=M[j];
  418.                             DecodeMulti(nr);
  419.                             goto aufbau1;
  420.                         }
  421.                     }
  422.     
  423.                     if (Check(x,y,548,606,42,52))                /* Print */
  424.                     {
  425.                         PrintMulti(nr);
  426.                         goto aufbau1;
  427.                     }
  428.     
  429.                     if (Check(x,y,548,606,57,67))                /* Rename */
  430.                     {
  431.                         char st[20];
  432.                         int i;
  433.     
  434.                         strstruct.titlebar        =NULL;
  435.                         strstruct.Window        =win;
  436.                         strstruct.visiblesize    =10;
  437.                         strstruct.versionnumber    =REQVERSION;
  438.                         strstruct.flags            =NULL;
  439.                         strstruct.rfu1            =NULL;
  440.                         strstruct.rfu2            =NULL;
  441.                         strstruct.rfu3            =NULL;
  442.     
  443.                         for (i=0;i<=9;i++) st[i]=m[nr][i];
  444.                         for (i=9;i>=0;i--) 
  445.                         {
  446.                             if (st[i] == 32) st[i]=0;
  447.                             else break;
  448.                         }
  449.                         st[10]='\0';
  450.     
  451.                         strstruct.stringbuffer    =&st[0];
  452.                         strstruct.stringsize    =11;
  453.     
  454.                         if (NewGetString(&strstruct))
  455.                         {
  456.                             int f;
  457.     
  458.                             for (f=0,i=0;i<=9;i++) 
  459.                             {
  460.                                 if (f == 0 && st[i] != 0) { m[nr][i]=st[i];  }
  461.                                             else {f=1; m[nr][i]=32;    }
  462.                             }
  463.                         }
  464.                         goto aufbau1;
  465.                     }        
  466.     
  467.                     if (Check(x,y,548,606,72,82))                       /* Initialize */
  468.                     {
  469.                         int j;
  470.     
  471.                         if (MyReq("Are you shure ?"," Yes ","Oh no"))
  472.                         {
  473.                             for (j=0;j<=75;j++) m[nr][j]=initmul[j];
  474.                             DecodeMulti(nr);
  475.                             goto aufbau1;
  476.                         }
  477.                     }    
  478.     
  479.     
  480.                     if (Check(x,y,548,606,87,97))                    /* Patch testen */
  481.                     {                
  482.                         TestMultiPatch();
  483.                         goto Loop;
  484.                     }    
  485.     
  486.                     if (Check(x,y,548,606,102,112))                    /* Copy */
  487.                     {
  488.                         int mx,my;
  489.     
  490.                         Make_MultiWindow("Copy to...");
  491.                         DisplayMultiEdWindow();
  492.             CopyLoop:    WaitPort(win7->UserPort);
  493.                         while (mesg=(struct IntuiMessage *) GetMsg(win7->UserPort))
  494.                         {
  495.                             ReplyMsg((struct Message *)mesg);
  496.                             mx=mesg->MouseX;
  497.                             my=mesg->MouseY;
  498.     
  499.                             if (mesg->Class == CLOSEWINDOW)
  500.                             {
  501.                                 CloseWindow(win7);
  502.                                 goto start;
  503.                             }
  504.     
  505.                             if (mesg->Class == MOUSEBUTTONS && mesg->Code == SELECTDOWN)
  506.                             {
  507.                                 if (mx>15 && mx<215 && my>15 && my<175)
  508.                                 {
  509.                                     int num;
  510.                 
  511.                                     ZZ_POINTER(win);
  512.                                     if (mx>15 && mx<215)    num=(my-15)/10*2+((mx<115)?0:1);
  513.                                     CloseWindow(win7);
  514.                                     EncodeMulti(nr);
  515.                                     for (i=0;i<=75;i++) m[num%32][i]=m[nr%32][i];
  516.                                     TransmitSingleMulti(num);
  517.                                     ProgChange(64+nr);    
  518.                                     CLEAR_POINTER(win);
  519.                                     goto Loop;
  520.                                 }
  521.                                 else
  522.                                 {
  523.                                     goto CopyLoop;
  524.                                 }    
  525.                             }
  526.                         }
  527.                         goto CopyLoop;
  528.                     }
  529.     
  530.                     if (Check(x,y,548,606,117,127))                    /* Swap*/
  531.                     {
  532.                         int mx,my;
  533.     
  534.                         Make_MultiWindow("Swap with...");
  535.                         DisplayMultiEdWindow();
  536.             SwapLoop:    WaitPort(win7->UserPort);
  537.                         while (mesg=(struct IntuiMessage *) GetMsg(win7->UserPort))
  538.                         {
  539.                             ReplyMsg((struct Message *)mesg);
  540.                             mx=mesg->MouseX;
  541.                             my=mesg->MouseY;
  542.     
  543.                             if (mesg->Class == CLOSEWINDOW)
  544.                             {
  545.                                 CloseWindow(win7);
  546.                                 goto start;
  547.                             }
  548.     
  549.                             if (mesg->Class == MOUSEBUTTONS && mesg->Code == SELECTDOWN)
  550.                             {
  551.                                 if (mx>15 && mx<215 && my>15 && my<175)
  552.                                 {
  553.                                     int num;
  554.     
  555.                                     if (mx>15 && mx<215)    num=(my-15)/10*2+((mx<115)?0:1);
  556.                                     ZZ_POINTER(win);
  557.                                     CloseWindow(win7);
  558.                                     EncodeMulti(nr);
  559.                                     for (i=0;i<=75;i++)
  560.                                     {
  561.                                         int h;
  562.                 
  563.                                         h=m[num][i];                
  564.                                         m[num][i]=m[nr][i];
  565.                                         m[nr][i]=h;
  566.                                     }
  567.                                     TransmitSingleMulti(nr);
  568.                                     TransmitSingleMulti(num);
  569.                                     ProgChange(nr);
  570.                                     DecodeMulti(nr);
  571.                                     for (i=0;i<=75;i++) M[i]=m[nr][i];            /* Daten sichern für Cancel */
  572.                                     CLEAR_POINTER(win);
  573.                                     goto aufbau1;
  574.                                 }
  575.                                 else
  576.                                 {
  577.                                     goto SwapLoop;
  578.                                 }    
  579.                             }
  580.                         }
  581.                         goto SwapLoop;
  582.                     }
  583.     
  584.     
  585.                         
  586.                     if (Check(x,y,15,115,30,150))                 /* SinglePatchSelect */
  587.                     {
  588.                         y-=30; 
  589.                     
  590.                         Make_SingleWindow("Please select sound");
  591.                         DisplaySingleEdWindow();
  592.                 loop:    WaitPort(win3->UserPort);
  593.                         while(mesg=(struct IntuiMessage *) GetMsg(win3->UserPort))
  594.                         {
  595.                             mx=mesg->MouseX;
  596.                             my=mesg->MouseY;
  597.     
  598.                             if (mesg->Class == CLOSEWINDOW)
  599.                             {
  600.                                 ReplyMsg((struct Message *)mesg);
  601.                                 CloseWindow(win3);
  602.                                 goto start;
  603.                             }
  604.     
  605.                             if (mesg->Class == MOUSEBUTTONS && mesg->Code == SELECTDOWN)
  606.                             {
  607.                                 if (mx>15 && mx<415 && my>15 && my<175)
  608.                                 {
  609.                                     int num;
  610.         
  611.                                     if (mx>15 && mx<215)    num=(my-15)/10*2+((mx<115)?0:1);
  612.                                     if (mx>215 && mx<415)    num=32+(my-15)/10*2+((mx<315)?0:1);
  613.                                     soundnr[y/15]=num%8;
  614.                                     banknr[y/15]=num/8;
  615.                                     ReplyMsg((struct Message *)mesg);
  616.                                     CloseWindow(win3);
  617.                                     DisplayLine(y/15);
  618.                                     EncodeMulti(nr);    
  619.                                     goto Loop;
  620.                                 }
  621.                                 else
  622.                                 {
  623.                                     ReplyMsg((struct Message *)mesg);
  624.                                     goto loop;
  625.                                 }    
  626.                             }
  627.                             ReplyMsg((struct Message *)mesg);
  628.                             goto loop;
  629.                         }
  630.                     }
  631.     
  632.                     if (Check(x,y,115,165,30,150))             /* ZoneLow */
  633.                     {
  634.                         int num=(y-30)/15;
  635.                     
  636.                         zonelow[num]=MultiProp(zonelow[num],127,0);
  637.                         DisplayLine(num);
  638.                         EncodeMulti(nr);    
  639.                         goto Loop;
  640.                     }
  641.     
  642.                     if (Check(x,y,165,215,30,150))             /* Zonehigh */
  643.                     {
  644.                         int num=(y-30)/15;
  645.                     
  646.                         zonehigh[num]=MultiProp(zonehigh[num],127,1);
  647.                         DisplayLine(num);
  648.                         EncodeMulti(nr);
  649.                         goto Loop;
  650.                     }
  651.                     
  652.                     if (Check(x,y,215,245,30,150))             /* RcvCh */
  653.                     {
  654.                         int num=(y-30)/15;
  655.     
  656.                         rcvch[num]=MultiProp(rcvch[num],15,2);
  657.                         DisplayLine(num);
  658.                         EncodeMulti(nr);
  659.                         goto Loop;
  660.                     }
  661.                     
  662.                     if (Check(x,y,245,295,30,150))            /* Velo */
  663.                     {                
  664.                         int num=(y-30)/15;
  665.                 
  666.                         velo[num]++;
  667.                         if (velo[num]>2) velo[num]=0;
  668.                         DisplayLine(num);
  669.                         EncodeMulti(nr);    
  670.                         goto Loop;
  671.                     }        
  672.     
  673.                     if (Check(x,y,295,335,30,150))             /* Output */
  674.                     {                
  675.                         int num=(y-30)/15;
  676.                 
  677.                         output[num]++;
  678.                         if (output[num]>3) output[num]=0;
  679.                         DisplayLine(num);
  680.                         EncodeMulti(nr);
  681.                         goto Loop;
  682.                     }
  683.     
  684.                     if (Check(x,y,335,365,30,150))             /* Poly */
  685.                     {    
  686.                         int sum;
  687.                         int num=(y-30)/15;
  688.     
  689.                         poly[num]=MultiProp(poly[num],9,6);
  690.                         DisplayLine(num);
  691.                         EncodeMulti(nr);
  692.                         goto Loop;
  693.                     }        
  694.     
  695.                     if (Check(x,y,365,415,30,150))             /* Mode */
  696.                     {                
  697.                         int num=(y-30)/15;
  698.                 
  699.                         mode[num]++;
  700.                         if (mode[num]>2) mode[num]=0;
  701.                         DisplayLine(num);
  702.                         EncodeMulti(nr);    
  703.                         goto Loop;
  704.                     }        
  705.     
  706.                     if (Check(x,y,415,455,30,150))             /*  Transpose */
  707.                     {
  708.                         int num=(y-30)/15;
  709.     
  710.                         transpose[num]=MultiProp(transpose[num],48,3);
  711.                         DisplayLine(num);
  712.                         EncodeMulti(nr);
  713.     
  714.                         goto Loop;
  715.                     }
  716.     
  717.                     if (Check(x,y,455,495,30,150))             /* Tune */
  718.                     {
  719.                         int num=(y-30)/15;
  720.     
  721.                         tune[num]=MultiProp(tune[num],100,4);
  722.                         DisplayLine(num);
  723.                         EncodeMulti(nr);
  724.                         goto Loop;
  725.                     }
  726.     
  727.                     if (Check(x,y,495,540,30,150))             /* Level */
  728.                     {
  729.                         int num=(y-30)/15;
  730.     
  731.                         level[num]=MultiProp(level[num],100,5);
  732.                         DisplayLine(num);
  733.                         EncodeMulti(nr);
  734.                         goto Loop;
  735.                     }
  736.                 } /* of SELECTDOWN */
  737.                  break;
  738.             } /* of case MOUSEBUTTONS */    
  739.             default: break;    
  740.         }
  741.     }
  742. goto Loop;
  743. }
  744.  
  745. /**********************************************************************************/
  746. /***                                                                            ***/
  747. /**********************************************************************************/
  748.  
  749. void DisplaySingleEdWindow(void)
  750. {
  751.     int i,n;    
  752.     char name[11];
  753.  
  754.     SetAPen(win3->RPort,2);
  755.     MakeBox(win3,15,13,415,93);
  756.     SetAPen(win3->RPort,1);    
  757.  
  758.     for (n=0;n<=31;n+=2)
  759.     {
  760.         Line(win3,15,13+n*5,415,13+n*5);
  761.         for (i=0;i<=9;i++) name[i]=s[0][n][i];
  762.         name[10]='\0';
  763.         Print(win3,20,21+n*5,name);
  764.  
  765.         for (i=0;i<=9;i++) name[i]=s[0][n+1][i];
  766.         name[10]='\0';
  767.         Print(win3,120,21+n*5,name);
  768.  
  769.         for (i=0;i<=9;i++) name[i]=s[1][n][i];
  770.         name[10]='\0';
  771.         Print(win3,220,21+n*5,name);
  772.  
  773.         for (i=0;i<=9;i++) name[i]=s[1][n+1][i];
  774.         name[10]='\0';
  775.         Print(win3,320,21+n*5,name);
  776.     }
  777.  
  778.     Line(win3,15,13+n*5,415,13+n*5);
  779.     Line(win3,15,13,15,13+n*5);
  780.     Line(win3,115,13,115,13+n*5);
  781.     Line(win3,215,13,215,13+n*5);
  782.     Line(win3,315,13,315,13+n*5);
  783.     Line(win3,415,13,415,13+n*5);
  784.  
  785.     SetAPen(win3->RPort,2);
  786.     MakeBox(win3,15,13,415,53);
  787.     MakeBox(win3,15,53,415,93);
  788.     MakeBox(win3,15,93,415,133);
  789.     MakeBox(win3,15,133,415,173);
  790.     MakeBox(win3,15,13,115,173);
  791.     MakeBox(win3,215,13,315,173);
  792.     SetAPen(win3->RPort,1);    
  793.  
  794. }    
  795.  
  796. /**********************************************************************************/
  797. /***                                                                            ***/
  798. /**********************************************************************************/
  799.  
  800. void DisplayMultiEdWindow(void)
  801. {
  802.     int i,n;    
  803.     char name[11];
  804.  
  805.     SetAPen(rp7,2);
  806.     MakeBox(win7,15,13,215,93);
  807.     SetAPen(rp7,1);    
  808.  
  809.     for (n=0;n<=31;n+=2)
  810.     {
  811.         Line(win7,15,13+n*5,215,13+n*5);
  812.         for (i=0;i<=9;i++) name[i]=m[n][i];
  813.         name[10]='\0';
  814.         Print(win7,20,21+n*5,name);
  815.  
  816.         for (i=0;i<=9;i++) name[i]=m[n+1][i];
  817.         name[10]='\0';
  818.         Print(win7,120,21+n*5,name);
  819.     }
  820.  
  821.     Line(win7,15,13+n*5,215,13+n*5);
  822.     Line(win7,15,13,15,13+n*5);
  823.     Line(win7,115,13,115,13+n*5);
  824.     Line(win7,215,13,215,13+n*5);
  825.  
  826.     SetAPen(rp7,2);
  827.     MakeBox(win7,15,13,215,53);
  828.     MakeBox(win7,15,53,215,93);
  829.     MakeBox(win7,15,93,215,133);
  830.     MakeBox(win7,15,133,215,173);
  831.     MakeBox(win7,15,13,115,173);
  832.     MakeBox(win7,215,13,215,173);
  833.     SetAPen(rp7,1);    
  834.  
  835. }    
  836.  
  837. /**********************************************************************************/
  838. /***                                                                            ***/
  839. /**********************************************************************************/
  840.  
  841. void EncodeMulti(int nr)
  842. {
  843.     int i,sum;
  844.  
  845.     if (nr>64)                        /* user cancel */
  846.     {
  847.         for (i=0;i<=75;i++) m[nr-128][i]=M[i];
  848.         nr=nr-128;
  849.         goto Transmit;
  850.     }
  851.  
  852.     mastervolume=99-Gadget1SInfo.VertPot/656;
  853.     mastervolume=mastervolume >99 ? 99 : mastervolume;
  854.  
  855.     for (i=0;i<=9;i++) if(m[nr][i]==0) m[nr][i]=32;
  856.  
  857.     for (i=0;i<=7;i++)                    /* kodiere */
  858.     {
  859.         m[nr][11+i]=(soundnr[i]+(banknr[i])*8) ;
  860.         m[nr][19+i]=zonelow[i] & 127;
  861.         m[nr][27+i]=zonehigh[i] & 127;
  862.         m[nr][35+i]=poly[i]+output[i]*16+(mode[i]%2)*64 ;
  863.         m[nr][43+i]=rcvch[i]+velo[i]*16+(mode[i]/2)*64 ;
  864.         m[nr][51+i]=transpose[i] & 127;
  865.         m[nr][58+i]=tune[i] & 127;
  866.         m[nr][67+i]=level[i] & 127;
  867.     }
  868.     
  869.     sum=0;
  870.     for (i=0;i<=7;i++)
  871.     {
  872.         if (poly[i]>=2) sum=sum+poly[i]-1;
  873.         if (sum>8)
  874.         {
  875.             poly[i]=0;
  876.             DisplayLine(i);
  877.             MyReq("Warning: Can't send data because\nthere are more than 8 voices.\nPlease set number of voices to\n0 or VR",NULL," Ok ");
  878.             return();
  879.         }
  880.     }
  881.  
  882.     m[nr][10]=mastervolume;
  883.     
  884.     sum=0xa5;                        /* Prüfsumme berechnen */
  885.     for (i=0;i<=74;i++) sum=(sum+m[nr][i]) & 127;
  886.     m[nr][75]=sum;
  887.     
  888. Transmit: ;
  889.     TransmitSingleMulti(nr);    
  890. }
  891.  
  892. /**********************************************************************************/
  893. /***                                                                            ***/
  894. /**********************************************************************************/
  895.  
  896. int MultiProp(int current,int max,int flag)
  897. {
  898.     struct Gadget     gad;
  899.     struct PropInfo prop;
  900.     char str[20];
  901.     long val;
  902.     char *flagstring[8]={"ZoneLow","ZoneHigh","RcvCh","Transpose","Tune","Level","Poly","Masterchn"};    
  903.  
  904.     str[0]=0;
  905.  
  906.     Make_PropWindow(current != 0 ? 120*current/max+6 : 12);
  907.     
  908.     prop.Flags=AUTOKNOB+FREEHORIZ;
  909.     prop.HorizPot=0;
  910.     prop.VertPot=-1;
  911.     prop.HorizBody=65535/max;
  912.     prop.VertBody=-1;    
  913.     
  914.     gad.NextGadget=NULL;
  915.     gad.LeftEdge=8;
  916.     gad.TopEdge=12;
  917.     gad.Width=125;
  918.     gad.Height=10;
  919.     gad.Flags=GADGHBOX;
  920.     gad.Activation=RELVERIFY+GADGIMMEDIATE;
  921.     gad.GadgetType=PROPGADGET;
  922.     gad.GadgetRender=(APTR)&Image1;
  923.     gad.SelectRender=NULL;
  924.     gad.GadgetText=NULL;
  925.     gad.MutualExclude=NULL;
  926.     gad.SpecialInfo=(APTR)∝
  927.     gad.GadgetID=0;
  928.     gad.UserData=0;
  929.  
  930.     prop.HorizPot=prop.HorizBody*current;
  931.     AddGadget(win4,&gad,-1); 
  932.     RefreshGadgets(&gad,win4,NULL); 
  933.  
  934.     strcat(str,flagstring[flag]);
  935.     Print(win4,10,9,&str[0]);
  936.  
  937.     val=prop.HorizPot/prop.HorizBody;
  938.     DisplayMultiValue(flag,val);
  939.  
  940. loop:    WaitPort(win4->UserPort);
  941.         mesg=(struct IntuiMessage *) GetMsg(win4->UserPort);
  942.     
  943.         if (mesg->Class == GADGETDOWN)
  944.         {
  945.             ReplyMsg((struct Message *)mesg);
  946.             while(gad.Flags & SELECTED) 
  947.             {
  948.                 val=prop.HorizPot/prop.HorizBody;
  949.                 DisplayMultiValue(flag,val);    
  950.             }
  951.             goto loop;
  952.         }
  953.  
  954.         if (mesg->Class == GADGETUP)
  955.         {
  956.             ReplyMsg((struct Message *)mesg);
  957.             val=prop.HorizPot/prop.HorizBody;
  958.             DisplayMultiValue(flag,val);
  959.  
  960.             goto loop;
  961.         }
  962.         
  963.         if (mesg->Class == MOUSEBUTTONS && mesg->Code==MENUDOWN)
  964.         {
  965.             ReplyMsg((struct Message *)mesg);
  966.             CloseWindow(win4);
  967.             return(prop.HorizPot/prop.HorizBody);
  968.         }
  969.  
  970.         ReplyMsg((struct Message *)mesg);
  971.         goto loop;
  972. }
  973.  
  974. /**********************************************************************************/
  975. /***                                                                            ***/
  976. /**********************************************************************************/
  977.  
  978. void DisplayMultiValue(int flag,int val)
  979. {
  980.     char str[255];
  981.  
  982.     if (flag==0) sprintf(str,"%2s%2ld",ToneName[val%12],(val/12)-2);
  983.     if (flag==1) sprintf(str,"%2s%2ld",ToneName[val%12],(val/12)-2);
  984.     if (flag==2) sprintf(str,"%3ld ",val+1);
  985.     if (flag==3) sprintf(str,"%3ld ",val-24);
  986.     if (flag==4) sprintf(str,"%3ld ",val-50);
  987.     if (flag==5) sprintf(str,"%3ld ",val);
  988.     if (flag==6)
  989.     {
  990.         if (val==0)  sprintf(str," VR");
  991.             else sprintf(str,"%3ld ",val-1);                    
  992.     }    
  993.     if (flag==7) sprintf(str,"%3ld ",val+1);
  994.     Print(win4,95,9,&str[0]);
  995. }
  996.  
  997. /**********************************************************************************/
  998. /***                      Multiparameter darstellen                              ***/
  999. /**********************************************************************************/
  1000.  
  1001. void DisplayLine(const int i)
  1002. {
  1003.         int j,nr,sn,bn,yp;
  1004.         char string[80],name[20];
  1005.  
  1006.         yp=40;
  1007.         sn=soundnr[i];
  1008.         bn=banknr[i];
  1009.  
  1010.         Line(win,15,30+15*i,540,30+15*i);
  1011.         
  1012.         nr=sn+8*(bn>3 ? bn-4 : bn);
  1013.         for (j=0;j<=9;j++) name[j]=s[bn>3 ? 1 : 0][nr][j];
  1014.         name[10]='\0';
  1015.         SetAPen(win->RPort,0);
  1016.         SetBPen(win->RPort,0);    
  1017.         SetOPen(win->RPort,0);
  1018.         RectFill(win->RPort,16,31+15*i,114,44+15*i);
  1019.  
  1020.         Print(win,23,15*i+yp,name);             /* Soundname */
  1021.         if (poly[i]==1) 
  1022.         {
  1023.             Line(win,16,31+15*i,114,44+15*i);
  1024.             Line(win,16,44+15*i,114,31+15*i);            
  1025.         }
  1026.         
  1027.         sprintf(string,"%2s%2ld ",ToneName[zonelow[i]%12],(int)(zonelow[i]/12)-2);
  1028.         Print(win,122,15*i+yp,string);
  1029.  
  1030.         sprintf(string,"%2s%2d ",ToneName[zonehigh[i]%12],(int)(zonehigh[i]/12)-2);
  1031.         Print(win,172,15*i+yp,string);
  1032.  
  1033.         sprintf(string,"%2ld ",rcvch[i]+1);
  1034.         Print(win,220,15*i+yp,string);
  1035.  
  1036.         if(velo[i]==0) strcpy(string,"All ");
  1037.         if(velo[i]==1) strcpy(string,"Soft");
  1038.         if(velo[i]==2) strcpy(string,"Loud");
  1039.         Print(win,254,15*i+yp,string);
  1040.  
  1041.         if(output[i]==0) strcpy(string," R ");
  1042.         if(output[i]==1) strcpy(string,"R+L");
  1043.         if(output[i]==2) strcpy(string," L ");
  1044.         if(output[i]==3) strcpy(string,"Byp");
  1045.         Print(win,302,15*i+yp,string);
  1046.  
  1047.         if(poly[i]==0) strcpy(string,"VR");
  1048.                   else sprintf(string,"%ld ",poly[i]-1);
  1049.         Print(win,342,15*i+yp,string);
  1050.  
  1051.         if(mode[i]==0) strcpy(string,"Keyb");
  1052.         if(mode[i]==1) strcpy(string,"Midi");
  1053.         if(mode[i]==2) strcpy(string,"Mix ");
  1054.         Print(win,374,15*i+yp,string);
  1055.  
  1056.         sprintf(string,"%3ld ",transpose[i]-24);
  1057.         Print(win,423,15*i+yp,string);
  1058.  
  1059.         sprintf(string,"%3ld ",tune[i]-50);
  1060.         Print(win,463,15*i+yp,string);
  1061.  
  1062.         sprintf(string,"%3ld ",level[i]);
  1063.         Print(win,503,15*i+yp,string);
  1064. }
  1065.  
  1066. /**********************************************************************************/
  1067. /***                                                                            ***/
  1068. /**********************************************************************************/
  1069.  
  1070. void TestMultiPatch(void)
  1071. {
  1072.     FILE *fp,*fopen();
  1073.     char com[2];
  1074.     int ie,err;
  1075.     static struct NewWindow nw;
  1076.     static struct Window     *WIN;
  1077.     static struct RastPort *RP;
  1078.     int             i,id;
  1079.     static char str[20];
  1080.     static char string[20][20];
  1081.     static struct GadgetBlock buf[17];
  1082.     int channel;
  1083.  
  1084.     nw.LeftEdge = 20;
  1085.     nw.TopEdge = 20;
  1086.     nw.Width = 145;
  1087.     nw.Height = 75;
  1088.     nw.DetailPen = 0;
  1089.     nw.BlockPen = 1;
  1090.     nw.Title ="  Select channel  dm";
  1091.     nw.Flags = RMBTRAP|ACTIVATE|REPORTMOUSE|SMART_REFRESH|WINDOWDRAG;
  1092.     nw.IDCMPFlags = MOUSEBUTTONS|GADGETUP|GADGETDOWN;
  1093.     nw.Type = (SCREEN != 0 ? CUSTOMSCREEN : WBENCHSCREEN);
  1094.     nw.CheckMark = NULL;
  1095.     nw.NextGadget=NULL;
  1096.     nw.Screen = (SCREEN != 0 ? scr : NULL);
  1097.     nw.BitMap = NULL;
  1098.     nw.MinWidth = 0;
  1099.     nw.MinHeight = 0;
  1100.     nw.MaxWidth = 0;
  1101.     nw.MaxHeight = 0;    
  1102.  
  1103.     nw.FirstGadget=NULL;
  1104.     for (i=0;i<=15;i++)
  1105.     {
  1106.         sprintf(string[i],"%2d",i+1);
  1107.         MakeGadget(&buf[i],&string[i][0],30*(i%4)+20,15*(i/4)+15);
  1108.         buf[i].Gadget.GadgetID=i+1;
  1109.         buf[i].Gadget.NextGadget=nw.FirstGadget;
  1110.         nw.FirstGadget=&buf[i].Gadget;
  1111.     }
  1112.         
  1113.     Center(&nw,-60,0);
  1114.     WIN=(struct Window *) OpenWindow(&nw);
  1115.     if (WIN==NULL) Error("Can't open channel-window");
  1116.     RP=WIN->RPort;
  1117.     SetFont(RP,textfont);
  1118.  
  1119. Loop: ;
  1120.     WaitPort(WIN->UserPort);
  1121.     mesg=(struct IntuiMessage *) GetMsg(WIN->UserPort);
  1122.     class=mesg->Class; 
  1123.     code=mesg->Code;
  1124.     id=mesg->IAddress->GadgetID;
  1125.     ReplyMsg((struct Message *)mesg);
  1126.  
  1127.     switch(class)
  1128.     {
  1129.         case MOUSEBUTTONS:
  1130.         {
  1131.             if (code==MENUDOWN)
  1132.             {
  1133.                 CloseWindow(WIN);
  1134.                 return();
  1135.             }    
  1136.             break;
  1137.         }
  1138.  
  1139.         case GADGETUP:
  1140.         {
  1141.             channel=id-1;
  1142.             goto Loop1;
  1143.             break;
  1144.         }
  1145.  
  1146.         default: goto Loop;
  1147.     }    
  1148.     goto Loop;
  1149.  
  1150. Loop1:    CloseWindow(WIN);
  1151.     TestSound(channel);    
  1152.  
  1153. }
  1154.